Skip to content

Migrate simple try-with-resources use of AgentScope to ContextScope#11763

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
mcculls/context-scope-migration-1
Jul 1, 2026
Merged

Migrate simple try-with-resources use of AgentScope to ContextScope#11763
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
mcculls/context-scope-migration-1

Conversation

@mcculls

@mcculls mcculls commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Motivation

Reduce use of AgentScope in the codebase - first round of migration

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: [PROJ-IDENT]

@mcculls mcculls force-pushed the mcculls/context-scope-migration-1 branch 2 times, most recently from cfdacad to 7ababa2 Compare June 29, 2026 10:51
@pr-commenter

pr-commenter Bot commented Jun 29, 2026

Copy link
Copy Markdown

Debugger benchmarks

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
ci_job_date 1782910397 1782910743
end_time 2026-07-01T12:54:42 2026-07-01T13:00:28
git_branch master mcculls/context-scope-migration-1
git_commit_sha ee7f3cc e312c12
start_time 2026-07-01T12:53:18 2026-07-01T12:59:04
See matching parameters
Baseline Candidate
ci_job_id 1820708364 1820708364
ci_pipeline_id 122093005 122093005
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
git_commit_date 1782909717 1782909717

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 9 metrics, 6 unstable metrics.

See unchanged results
scenario Δ mean agg_http_req_duration_min Δ mean agg_http_req_duration_p50 Δ mean agg_http_req_duration_p75 Δ mean agg_http_req_duration_p99 Δ mean throughput
scenario:noprobe unstable
[-21.864µs; +30.278µs] or [-7.499%; +10.385%]
unstable
[-32.137µs; +43.770µs] or [-9.619%; +13.100%]
unstable
[-41.501µs; +60.012µs] or [-11.886%; +17.187%]
unstable
[-122.997µs; +100.845µs] or [-10.122%; +8.299%]
same
scenario:basic same same same unstable
[-193.385µs; +74.716µs] or [-16.330%; +6.309%]
unstable
[-140.816op/s; +140.816op/s] or [-5.633%; +5.633%]
scenario:loop same same same same same
Request duration reports for reports
gantt
    title reports - request duration [CI 0.99] : candidate=None, baseline=None
    dateFormat X
    axisFormat %s
section baseline
noprobe (334.115 µs) : 304, 364
.   : milestone, 334,
basic (294.85 µs) : 288, 302
.   : milestone, 295,
loop (8.972 ms) : 8966, 8977
.   : milestone, 8972,
section candidate
noprobe (339.931 µs) : 298, 381
.   : milestone, 340,
basic (292.935 µs) : 287, 299
.   : milestone, 293,
loop (8.972 ms) : 8966, 8978
.   : milestone, 8972,
Loading
  • baseline results
Scenario Request median duration [CI 0.99]
noprobe 334.115 µs [304.408 µs, 363.821 µs]
basic 294.85 µs [287.957 µs, 301.744 µs]
loop 8.972 ms [8.966 ms, 8.977 ms]
  • candidate results
Scenario Request median duration [CI 0.99]
noprobe 339.931 µs [298.43 µs, 381.432 µs]
basic 292.935 µs [286.733 µs, 299.137 µs]
loop 8.972 ms [8.966 ms, 8.978 ms]

@dd-octo-sts

dd-octo-sts Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.97 s 13.96 s [-0.9%; +1.0%] (no difference)
startup:insecure-bank:tracing:Agent 12.93 s 12.96 s [-0.8%; +0.5%] (no difference)
startup:petclinic:appsec:Agent 16.82 s 16.54 s [+0.8%; +2.5%] (maybe worse)
startup:petclinic:iast:Agent 16.94 s 17.00 s [-1.2%; +0.5%] (no difference)
startup:petclinic:profiling:Agent 16.92 s 16.95 s [-1.2%; +0.8%] (no difference)
startup:petclinic:sca:Agent 16.90 s 16.85 s [-0.7%; +1.3%] (no difference)
startup:petclinic:tracing:Agent 16.09 s 16.05 s [-0.8%; +1.2%] (no difference)

Commit: e312c12e · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@pr-commenter

pr-commenter Bot commented Jun 29, 2026

Copy link
Copy Markdown

Kafka / producer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master mcculls/context-scope-migration-1
git_commit_date 1782901139 1782909717
git_commit_sha ee7f3cc e312c12
See matching parameters
Baseline Candidate
ci_job_date 1782910756 1782910756
ci_job_id 1820708361 1820708361
ci_pipeline_id 122093005 122093005
cpu_model Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz
jdkVersion 11.0.25 11.0.25
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/go/src/github.com/DataDog/apm-reliability/dd-trace-java/platform/src/producer-benchmark/build/tmp/jmh -Duser.country=US -Duser.language=en -Duser.variant -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/go/src/github.com/DataDog/apm-reliability/dd-trace-java/platform/src/producer-benchmark/build/tmp/jmh -Duser.country=US -Duser.language=en -Duser.variant
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.25+9-post-Ubuntu-1ubuntu122.04 11.0.25+9-post-Ubuntu-1ubuntu122.04

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaProduceBenchmark.benchProduce same

@pr-commenter

pr-commenter Bot commented Jun 29, 2026

Copy link
Copy Markdown

Kafka / consumer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master mcculls/context-scope-migration-1
git_commit_date 1782901139 1782909717
git_commit_sha ee7f3cc e312c12
See matching parameters
Baseline Candidate
ci_job_date 1782910807 1782910807
ci_job_id 1820708363 1820708363
ci_pipeline_id 122093005 122093005
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
jdkVersion 11.0.25 11.0.25
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/go/src/github.com/DataDog/apm-reliability/dd-trace-java/platform/src/consumer-benchmark/build/tmp/jmh -Duser.country=US -Duser.language=en -Duser.variant -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/go/src/github.com/DataDog/apm-reliability/dd-trace-java/platform/src/consumer-benchmark/build/tmp/jmh -Duser.country=US -Duser.language=en -Duser.variant
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.25+9-post-Ubuntu-1ubuntu122.04 11.0.25+9-post-Ubuntu-1ubuntu122.04

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaConsumerBenchmark.benchConsume same

@mcculls mcculls marked this pull request as ready for review June 29, 2026 12:05
@mcculls mcculls requested review from a team as code owners June 29, 2026 12:05
@mcculls mcculls requested review from PerfectSlayer, claponcet, jandro996, mhlidd, tylfin and vandonr and removed request for a team June 29, 2026 12:05

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: PASS

More details

Uniform mechanical refactor across 88 files: every try-with-resources variable declaration changes from AgentScope to ContextScope, which is a valid widening reference conversion because AgentScope extends ContextScope. No method calls on the scope variable are added or removed; all callers (activateSpan, activateManualSpan, continuation.activate()) continue to return AgentScope at runtime, so close() dispatches identically via virtual method invocation. Null-scope safety in Wrapper.java is preserved by the JLS try-with-resources spec.

Was this helpful? React 👍 or 👎

📊 Validated against 4 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit 7ababa2 · What is Autotest? · Any feedback? Reach out in #autotest

@jpbempel jpbempel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for debugger code

@daniel-mohedano daniel-mohedano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM wrt CiVis changes

@mcculls mcculls force-pushed the mcculls/context-scope-migration-1 branch from 7ababa2 to e312c12 Compare July 1, 2026 12:42
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 28.57%
Overall Coverage: 54.44% (-0.60%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e312c12 | Docs | Datadog PR Page | Give us feedback!

@mcculls mcculls added this pull request to the merge queue Jul 1, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 1, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-01 15:26:45 UTC ℹ️ Start processing command /merge


2026-07-01 15:26:50 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 2h (p90).


2026-07-01 16:45:29 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 1, 2026
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit dc67b24 into master Jul 1, 2026
594 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the mcculls/context-scope-migration-1 branch July 1, 2026 16:45
@github-actions github-actions Bot added this to the 1.64.0 milestone Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants